import request from '@/utils/request';
import { type Audit, type AuditQueryParams, type AuditRequest, type PageResult } from '../../types/app';

/**
 * 分页查询审核列表
 * @param params 查询参数
 * @returns 分页结果
 */
export function getAuditPage(params: AuditQueryParams) {
  return request<PageResult<Audit>>({
    url: '/api/audits',
    method: 'get',
    params
  });
}

/**
 * 获取应用最新的审核记录
 * @param appId 应用ID
 * @returns 审核记录
 */
export function getLatestAudit(appId: number) {
  return request<Audit>({
    url: `/api/audits/latest/${appId}`,
    method: 'get'
  });
}

/**
 * 提交审核
 * @param data 审核数据
 * @returns 审核ID
 */
export function submitAudit(data: AuditRequest) {
  return request<number>({
    url: '/api/audits',
    method: 'post',
    data
  });
}

/**
 * 获取待审核应用数量
 * @returns 待审核应用数量
 */
export function getPendingAuditCount() {
  return request<number>({
    url: '/api/audits/pending/count',
    method: 'get'
  });
}

/**
 * 获取开发者待审核应用数量
 * @returns 待审核应用数量
 */
export function getDeveloperPendingAuditCount() {
  return request<number>({
    url: '/api/audits/developer/pending/count',
    method: 'get'
  });
}
